<%@page import="java.util.List"%>
<%@page import="ua.org.energy.vkek.site.web.JSPHelper"%>
<%@page import="ua.org.energy.vkek.site.model.Article"%>
<%@page import="ua.org.energy.vkek.site.model.ArticleTag"%>
<%@page import="ua.org.energy.vkek.site.server.TagUtils"%>
<%@page import="ua.org.energy.vkek.site.model.ArticleCategory"%>
<%@page import="ua.org.energy.vkek.site.server.EMF"%>
<%@page import="ua.org.energy.vkek.site.server.CategoryUtils"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Восточно-Крымская Энергетическая Компания:Карта сайта</title>
        <link rel="stylesheet" href="/css/site.css"/>
        <style type="text/css">

            .level1 {
                border: solid thin cadetblue;
                border-radius: 3px; 
                font-size: x-large;
                padding-left: 0px;
            }
            .level2 {
                font-size: medium;
            }
            .level3 {

            }
            .level1>li {
                background: #e1e1fe;
                margin-top: 3px;
                margin-bottom: 0px;
                padding-left:  3px;
                cursor: pointer;
                list-style-position: inside;
            }
            .level3>li{
                background: #ffffcc;
                margin-top: 0px;
                margin-bottom: 0px;
                padding: 3px;
            }
            .collapsed {
                float: right;
                width:33px;
                height:33px; 
                background-image: url("/i/more_32x32.png");
                background-repeat: no-repeat;
                background-position:center;
                background-color: #e1e1fe;
                display:block;
            }
            .mh {
                min-height: 34px;
            }
        </style>
        <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
        <script type="text/javascript">
            $(document).ready(function (event) {
               
                                
                $(".level1>li").click(function(event){
                    if ($(event.target).is("a")) {
                        return;
                    }
                    if ($("+ .slider",this).find("li").size()==0){
                        return;
                    }
                    $("+.slider",this).slideToggle("normal");
                    $(this).toggleClass("mh");
                    $(".marker",this).toggleClass("collapsed");
                });
                    
                    
            });
        </script>

    </head>
    <body>

      <div id="wrap">
            <%@include file="/WEB-INF/jspf/header.jspf" %>

            <div  class="bordered" style="margin-top: 3px;">
                <p style="text-align: center"> Карта сайта:</p>
            </div>

            <%
                int i = 0;
                String urlPrefix = "";
                CategoryUtils cu = new CategoryUtils(EMF.getEM());

                List<ArticleCategory> cl = cu.listAll();
                out.println("<ul class=\"level1\">");
                for (ArticleCategory ac : cl) {
                    i++;
                    urlPrefix = (i == 1) ? JSPHelper.INDEX_PAGE : JSPHelper.SITE_PAGE;

                    out.println("<li>" + JSPHelper.constructSiteHyperLink(ac, urlPrefix,null) + "<div class=\"marker\"></div></li>");
                    out.println("<div class=\"slider\">");
                    List<ArticleTag> tl = ac.getArticleTags();

                    out.println("<ul class=\"level2\">");
                    for (ArticleTag at : tl) {
                        out.println("<li>" + JSPHelper.constructSiteHyperLink(at, urlPrefix,null) + "</li>");
                        List<Article> al = at.getArticles();
                        out.println("<ul class=\"level3\">");
                        for (Article a : al) {
                            out.println("<li>" + JSPHelper.constructSiteHyperLink(a, urlPrefix,null)
                                    + "<span style=\"float:right\">" + JSPHelper.getDateStr(a.getArticleDate()) + "</span></li>");
                        }
                        out.println("</ul>");
                    }
                    out.println("</ul>");
                    out.println("</div>");

                }
                out.println("</ul>");
            %>
            <%@include file="/WEB-INF/jspf/footer.jspf"%>
        </div>
    </body>
</html>
